package com.example.administrator.printoutindemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;


public class StoreListMonthkedAdapter extends BaseAdapter{
	private Context mContext = null;
	private List<Mothsked> li = null;
	private LayoutInflater mInflater = null;

	private class ViewHolder {
		TextView s_list_txt;
	}
	private ViewHolder holder = null;

	public StoreListMonthkedAdapter(Context mContext) {
		this.mContext = mContext;
	}

	public void setList(List<Mothsked> li) {
		this.li = li;
		this.mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return li.size();
	}
	@Override
	public Object getItem(int position) {
		return li.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (null == convertView) {
			holder = new ViewHolder();

			convertView = mInflater.inflate(R.layout.store_adapter_listmonthked, null);

			holder.s_list_txt = (TextView) convertView
					.findViewById(R.id.s_list_txt);


			convertView.setTag(holder);
		}
		else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (null != this.li) {

			Mothsked o = li.get(position);

			int status = o.getMstatus();
			String str = "";
			if (status == 2) {
				str = "抽检完成";
			}
			if (status == 3) {
				str = "封装";
			}
			if (status == 4) {
				str = "送检";
			}

			holder.s_list_txt.setText("物料描述："+o.getMaterial()+"\n状态： "+str);

		}

		return convertView;
	}


}